home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / XandSysPerf / Xscope.text < prev   
Encoding:
Text File  |  1994-08-02  |  7.3 KB  |  233 lines

  1.  
  2.                               xscope briefer
  3.  
  4. Knowledge to walk away with:
  5.  
  6.  o  Fundamental performance aspects of the X protocol.
  7.  
  8.  o  Use of xscope for X protocol tracing.
  9.  
  10.  o  Basics of X protocol anaylsis.
  11.  
  12.      Fundamentals of the X protocol:
  13.  
  14.          o  Requires reliable, byte stream (TCP, Unix sockets, shared
  15.         memory transport all work).
  16.  
  17.          o  Client generates requests.
  18.  
  19.          o  Server generates replies, events, and errors.
  20.  
  21.          o  Creating resources does not require round-trip;  clients 
  22.         pick IDs from client's ID range.
  23.  
  24.      Inherent performance bottleneck:
  25.  
  26.          o  Non-reply requests can be queued and batched.
  27.  
  28.          o  But requests with replies = round-trips = slow.
  29.  
  30.          o  Replies cause client/server context switching.
  31.  
  32.          o  Replies lower I/O throughput by making queuing difficult.
  33.  
  34.         Round-trip statistics:
  35.  
  36.          o  16Mb Indy SC       (operations/second)
  37.             -    530,000        10-pixel segements (batched)
  38.             -    225,000        NoOperation requests
  39.             -     35,000        1-pixel triangles
  40.             -     14,000        10x10 PutImage requests
  41.  
  42.             -        930        GetProperty requests
  43.             -        775        10x10 GetImage requests
  44.  
  45.          o  Notice 2-3 order of magnitude difference in request rate.
  46.  
  47.          o  45 round trips @ 1/20 second
  48.  
  49.    Peeking at the X protocol stream:
  50.  
  51.         o  xscope is a pseudo-server
  52.  
  53.  
  54.  
  55.     ___________                  ___________                  ______________
  56.     |         | Requests         |         |  Requests        |            |
  57.     |         | -------------->  |         |  --------------> |            |
  58.     |    X    |                  |         |                  |  Xsgi      |
  59.     |         | <--------------- | xscope  | <--------------- |            |
  60.     | Client  |   Replies,       |         |   Replies,       |            |
  61.     |         |   Events,        |         |   Events,        |            |
  62.     |         |   Errors         |         |   Errors         |            |
  63.     |_________|                  |_________|                  |____________|
  64.                                       |
  65.                                       |
  66.                                       |
  67.                                       V
  68.                                X protocol trace
  69.                                   to stdout
  70.  
  71.  
  72.         o  Setting DISPLAY to the `fake' display makes client use xscope.
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80. Sample X protocol
  81. trace from 
  82. xscope:
  83.  
  84.  
  85. Notice:
  86.   Timestamps
  87.   Client and server writes
  88.   Decoded requests and replies
  89.  
  90.  
  91.  
  92.  0.00: Client -->   12 bytes
  93.                   byte-order: MSB first
  94.                major-version: 000b
  95.                minor-version: 0000
  96.  0.04:                                   520 bytes <-- X11 Server
  97.                                         protocol-major-version: 000b
  98.                                         protocol-minor-version: 0000
  99.                                               release-number: 00001388
  100.                                             resource-id-base: 0b800000
  101.                                             resource-id-mask: 003fffff
  102.                                           motion-buffer-size: 00000000
  103.                                             image-byte-order: MSB first
  104.                                         bitmap-format-bit-order: MSB first
  105.                                         bitmap-format-scanline-unit: 20
  106.                                         bitmap-format-scanline-pad: 20
  107.                                                  min-keycode: 10 (^J)
  108.                                                  max-keycode: 118 (v)
  109.                                                       vendor: "Silicon Graphics"
  110.                                               pixmap-formats: (4)
  111.                                                        roots: (2)
  112.  0.05: Client -->   84 bytes
  113.          ............REQUEST: CreateGC
  114.           graphic-context-id: GXC 0b800000
  115.                     drawable: DWB 0000002a
  116.                   value-mask: background
  117.                   value-list:
  118.                           background: 00000007
  119.          ............REQUEST: CreateGC
  120.           graphic-context-id: GXC 0b800001
  121.                     drawable: DWB 0000002c
  122.                   value-mask: background
  123.                   value-list:
  124.                           background: 00000007
  125.          ............REQUEST: QueryExtension
  126.                         name: "BIG-REQUESTS"
  127.          ............REQUEST: GetProperty
  128.                       delete: False
  129.                       window: WIN 0000002a
  130.                     property: <RESOURCE_MANAGER>
  131.                         type: <STRING>
  132.                  long-offset: 00000000
  133.  0.10:                                   104 bytes <-- X11 Server
  134.                                          ..............REPLY: QueryExtension
  135.                                                      present: False
  136.                                                 major-opcode: 00
  137.                                                  first-event: 00
  138.                                                  first-error: 00
  139.  
  140.  
  141.  
  142.  
  143. Generating a trace with xscope:
  144.  
  145.  1)  Shell #1: setenv DISPLAY foobar:0
  146.  
  147.      2)  Shell #1: xscope >& trace_file
  148.  
  149.      3)  Shell #2: setenv DISPLAY foobar:1
  150.  
  151.      4)  Shell #2: run X client like: xlogo
  152.  
  153.  5)  Shell #2: ^C or kill client
  154.  
  155.      6)  Shell #1: ^C the xscope
  156.  
  157.      7)  examine trace_file...
  158.  
  159.  
  160.  
  161.         
  162. Introduction to X protocol analysis:
  163.  
  164.      o  Helps to have X Protocol Reference Manual Volume 0 handy.
  165.      o  Question round-trips.
  166.      o  Look for duplicate requests.
  167.      o  Leaking pixmaps or freeing pixmaps before using.
  168.      o  Drawing to unmapped windows.
  169.      o  Unneeded events, for example NoExpose.
  170.      o  Interning atoms.  Why?
  171.      o  Opening duplicate fonts?
  172.      o  Requesting QueryColors repeatedly?
  173.  
  174.  
  175.  
  176.  
  177. Using xprotostats for quick overview:
  178.  
  179.  
  180. hoot% xprotostats < ICONBOOK.xscope
  181.  
  182. RAW CLIENT PROTOCOL STATISITICS:
  183.   bytes written:              41488
  184.   batches written:              409
  185.   requests made:               1850
  186. RAW SERVER PROTOCOL STATISITICS:
  187.   bytes written:              74412
  188.   batches written:              419
  189.   replies made:                 420
  190.   events sent:                  104
  191.   errors sent:                    0
  192. COMPUTED STATISTICS:
  193.   replies/request:            22.70 %
  194.   server/client data:        179.36 %
  195.   bytes/request:              22.43 bytes
  196. OFTEN MISUSED ROUND-TRIP REQUESTS:
  197.   AllocColor                     42
  198.   AllocNamedColor                 8
  199.   GetGeometry                    30
  200.   GetInputFocus                  30
  201.   GetKeyboardMapping             17
  202.   GetSelectionOwner               2
  203.   GetWindowAttributes            20
  204.   InternAtom                     49
  205.   ListFonts                       3
  206.   ListProperties                  3
  207.   QueryBestSize                   1
  208.   QueryColors                   170
  209.   QueryExtension                  3
  210.   QueryFont                      10
  211.   QueryTree                       2
  212.   TranslateCoordinates            1
  213. OFTEN MISUSED EVENTS:
  214.   NoExposure                     31
  215.  
  216. hoot%
  217.  
  218.  
  219.  
  220.  
  221.  
  222. Getting more information:
  223.  
  224.          o   Read the xscope man page.
  225.  
  226.          o   Peterson & Chang, ``Improving X Application Performance,'' 
  227.          The X Resource, Summer 92.
  228.  
  229.          o   O'Reilly & Associates' X Protocol Reference Manual Volume 0.
  230.  
  231.          o   Marks & Cable, ``Trace Analysis of the X Window System 
  232.          Protocol,'' 7th X Tech Conference, 1993.
  233.